# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=pipewire
pkgver=0.3.9
pkgrel=0
pkgdesc="Multimedia processing graphs"
url="https://pipewire.org/"
arch="all"
license="LGPL-2.1-or-later"
makedepends="meson alsa-lib-dev libx11-dev sdl2-dev ffmpeg-dev eudev-dev dbus-dev
	glib-dev gstreamer-dev gst-plugins-base-dev sbc-dev doxygen xmltoman graphviz
	bluez-dev jack-dev vulkan-loader-dev pulseaudio-dev"
options="!check" # no tests
subpackages="$pkgname-dev $pkgname-doc $pkgname-pulse $pkgname-jack"
source="$pkgname-$pkgver.tar.gz::https://github.com/PipeWire/pipewire/archive/$pkgver.tar.gz"

build() {
	abuild-meson \
		-Ddocs=true \
		-Dman=true \
		-Dgstreamer=true \
		-Dexamples=true \
		-Dffmpeg=true \
		-Dsystemd=false \
		. output
	ninja -C output
}

package() {
	DESTDIR="$pkgdir" ninja -C output install
}

pulse() {
	pkgdesc="Pulseaudio support for pipewire"
	mkdir -p "$subpkgdir/usr/lib/$pkgname-${pkgver:0:3}"
	mkdir -p "$subpkgdir/usr/bin"
	mv "$pkgdir/usr/lib/$pkgname-${pkgver:0:3}/pulse" \
	   "$subpkgdir/usr/lib/$pkgname-${pkgver:0:3}/"
	mv "$pkgdir/usr/bin/pw-pulse" "$subpkgdir/usr/bin/"
}

jack() {
	pkgdesc="JACK support for pipewire"
	mkdir -p "$subpkgdir/usr/lib/$pkgname-${pkgver:0:3}"
	mkdir -p "$subpkgdir/usr/bin"
	mv "$pkgdir/usr/lib/$pkgname-${pkgver:0:3}/jack" \
	   "$subpkgdir/usr/lib/$pkgname-${pkgver:0:3}/"
	mv "$pkgdir/usr/bin/pw-jack" "$subpkgdir/usr/bin/"
}

sha512sums="f2db26e554def1566cb11ff0ea73c31890fb9dd666d9650dcac351ba2a7407e0b5e6c4cc8f11f6290c00845824f97c205b6d3162598d5906fd97f80f56f6a061  pipewire-0.3.9.tar.gz"
